require 'test/unit'
require 'lib/smppclient/pdu/enquire_link'
require 'lib/smppclient/util/byte_buffer'

class TestEnquireLink < MiniTest::Unit::TestCase

  include SmppClient::Pdu
  include SmppClient::Util

  def test_bytes_to_object
    bb = ByteBuffer.new
    bb.append_int(16)
    bb.append_int(0x00000015)
    bb.append_int(0)
    bb.append_int(1000123456)

    el = EnquireLink.new(bb)
    assert_equal(16, el.command_length)
    assert_equal(CommandId::ENQUIRE_LINK, el.command_id)
    assert_equal(CommandStatus::ESME_ROK, el.command_status)
    assert_equal(1000123456, el.sequence_number)
  end

  def test_object_to_bytes
    el = EnquireLink.new
    assert_equal(Pdu::HEADER_LENGTH, el.command_length)
    assert_equal(CommandId::ENQUIRE_LINK, el.command_id)
    assert_equal(CommandStatus::ESME_ROK, el.command_status)
    assert_equal(0, el.sequence_number)
    assert_equal('00000010000000150000000000000000', el.buffer.to_s)
  end

end